//
// Created by hjie on 23-6-11.
//
#pragma once
#include <cstring>
#include <string>
#include <thread>
#include <memory>
#include <unistd.h>
#include <mutex>
#include <sys/time.h>
extern "C"
{
    #include <libavcodec/codec.h>
    #include <libavformat/avformat.h>
    #include <libavutil/avutil.h>
    #include <libavutil/frame.h>
    #include <libavcodec/avcodec.h>
    #include <libavcodec/packet.h>
    #include <libavutil/threadmessage.h>
}

class MediaProcess : public std::enable_shared_from_this<MediaProcess>
{
public:
    MediaProcess(const std::string & file_name);
    ~MediaProcess();
    void StartReadThread();
    int GetAvPacket(AVPacket ** packet);
private:
    void ReadAvPacket();
private:
    std::mutex m_mtx;
    AVThreadMessageQueue * m_thread_msg_queue;
    std::thread m_thd;
    std::string m_file_name;
};



